﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebBasicInfo;
using Base;


public partial class admin_Basic_FilterKeyword : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckRights("Basic", "A1");
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        IWebBasicInfo RWeb = new RWebBasicInfo();
        TWebBasicInfo TWeb = RWeb.GateItem();
        txtContent.Value = TWeb.Filter;
      
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            TWebBasicInfo TWeb = new TWebBasicInfo();
            string content = txtContent.Value;

            if (content.Contains("，"))
            {
                content=content.Replace("，", ",");
            }
            if (content.LastIndexOf(",") + 1 >= content.Length)
            {
                content=content.Substring(0, content.Length - 1);
            }
            string[] myvalue = content.Split(',');
            for (int i = 0; i < myvalue.Length; i++)
            {
                for (int j =i+1; j < myvalue.Length; j++)
                {
                    if (myvalue[i] == myvalue[j])
                    {
                        ShowMessage("不能插入重复的过滤字");
                        return;
                    }
                }
            }
                TWeb.Filter = content;
            IWebBasicInfo RWeb = new RWebBasicInfo();
            RWeb.UpdateFilter(TWeb);
            ShowMessage("关键字过滤修改成功！","Basic/FilterKeyword.aspx");
        }
        catch (Exception ex)
        {

            ShowMessage("关键字过滤修改失败!", "Basic/FilterKeyword.aspx");
        }
    }
}
